package com.canyou.common;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 导入结果信息模型
 *
 * @author cd
 */
@Data
@ApiModel(value = "DataImportVO", description = "导入结果信息模型")
public class DataImportVO {

    @ApiModelProperty("导入成功数据条数")
    private Integer successCount;

    @ApiModelProperty("导入失败数据集合")
    private List<Integer> failList;

    @ApiModelProperty("不规范数据集合")
    private List<Integer> illegalList;

    @ApiModelProperty("失败数据详细信息")
    private String importMsg;

    /**
     * 构建导入结果信息
     *
     * @return
     */
    public DataImportVO setMsg() {
        String failIndex = StrUtil.join(",", getFailList());
        String illegalIndex = StrUtil.join(",", getIllegalList());
        String msg = "本次导入,成功" + getSuccessCount() + "条,导入失败" + getFailList().size() + "条,"
                + "数据错误" + getIllegalList().size() + "条;<br/>其中第" + failIndex + "条数据导入失败,"
                + "第" + illegalIndex + "条数据数据异常。";
        this.setImportMsg(msg);
        return this;
    }

}
